<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>

<body>
  <div id="app">
    <custom-user name="xiaoming" :age="20" :city="['北京','太原']"></custom-user>

    <base-checkbox v-model="ischecked" ></base-checkbox>
  </div>
  <script>

    Vue.component('custom-user', {
      // props:['name'],
      props: {
        name: {
          type: String,
          required: true,
        },
        age: Number,
        city: {
          validator(value) {
            return value.indexOf('太原') > -1;
          }
        }
      },
      template: `<div>0</div>`
    })

    Vue.component('base-checkbox', {
      model: {
        prop: 'checked',
        event: 'change'
      },
      props: {
        checked: Boolean
      },
      template: `
    <input
      type="checkbox"
      v-bind:checked="checked"
      v-on:change="$emit('change', $event.target.checked)"
    >
  `
    })


    var vm = new Vue({
      el: "#app",
      data:{
        ischecked:true
      }
    })
  </script>
</body>

</html>